package com.ruoyi.system.service.impl;

import java.util.HashMap;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysNaireMapper;
import com.ruoyi.system.domain.SysNaire;
import com.ruoyi.system.service.ISysNaireService;

/**
 * 问卷数据Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-05-20
 */
@Service
public class SysNaireServiceImpl implements ISysNaireService 
{
    @Autowired
    private SysNaireMapper sysNaireMapper;

    /**
     * 查询问卷数据
     * 
     * @param naireId 问卷数据主键
     * @return 问卷数据
     */
    @Override
    public SysNaire selectSysNaireByNaireId(Long naireId)
    {
        return sysNaireMapper.selectSysNaireByNaireId(naireId);
    }

    /**
     * 查询问卷数据列表
     * 
     * @param sysNaire 问卷数据
     * @return 问卷数据
     */
    @Override
    public List<SysNaire> selectSysNaireList(SysNaire sysNaire)
    {
        return sysNaireMapper.selectSysNaireList(sysNaire);
    }

    /**
     * 新增问卷数据
     * 
     * @param sysNaire 问卷数据
     * @return 结果
     */
    @Override
    public int insertSysNaire(SysNaire sysNaire)
    {
        sysNaire.setCreateTime(DateUtils.getNowDate());
        return sysNaireMapper.insertSysNaire(sysNaire);
    }

    /**
     * 修改问卷数据
     * 
     * @param sysNaire 问卷数据
     * @return 结果
     */
    @Override
    public int updateSysNaire(SysNaire sysNaire)
    {
        sysNaire.setUpdateTime(DateUtils.getNowDate());
        return sysNaireMapper.updateSysNaire(sysNaire);
    }

    /**
     * 批量删除问卷数据
     * 
     * @param naireIds 需要删除的问卷数据主键
     * @return 结果
     */
    @Override
    public int deleteSysNaireByNaireIds(Long[] naireIds)
    {
        return sysNaireMapper.deleteSysNaireByNaireIds(naireIds);
    }

    /**
     * 删除问卷数据信息
     * 
     * @param naireId 问卷数据主键
     * @return 结果
     */
    @Override
    public int deleteSysNaireByNaireId(Long naireId)
    {
        return sysNaireMapper.deleteSysNaireByNaireId(naireId);
    }

    @Override
    public HashMap<Long, String> getNaireNameMap() {
        HashMap<Long, String> maps=new HashMap<>();
        SysNaire sysNaire=new SysNaire();
        List<SysNaire> naires=selectSysNaireList(sysNaire);
        for(SysNaire naire:naires){
            maps.put(naire.getNaireId(),naire.getName());
        }
        return maps;
    }
}
